//
//  THBaseTableViewCell.m
//  M-Saler
//
//  Created by Teresa on 2020/5/21.
//  Copyright © 2020 Teresa. All rights reserved.
//

#import "THBaseTableViewCell.h"

@implementation THBaseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (CGFloat)height{
    return 44.f;
}

+(void)registerToTableView:(UITableView *)tableView{
    
    NSString *nibPath = [[NSBundle mainBundle]pathForResource:self.nameOfClass ofType:@"nib"];
    if (nibPath) {
        UINib *cellNib = [UINib nibWithNibName:self.nameOfClass bundle:nil];
        [tableView registerNib:cellNib forCellReuseIdentifier:self.nameOfClass];
    }else{
        [tableView registerClass:[self class] forCellReuseIdentifier:self.nameOfClass];
    }
}

-(NSIndexPath *)indexPath{
    UIView *superView = self.superview;
    while (superView != nil) {
        if ([superView isKindOfClass:[UITableView class]]) {
            UITableView *tableView = (UITableView*)superView;
            return [tableView indexPathForCell:self];
        }else{
            superView = superView.superview;
        }
    }
    return nil;
}


@end
